/******************************************************************************

  Copyright (C), 2001-2011, Hisilicon Tech. Co., Ltd.

 ******************************************************************************
  File Name     : mplayer.c
  Version       : Initial Draft
  Author        : Hisilicon multimedia software group
  Created       : 2010/01/26
  Description   :
  History       :
  1.Date        : 2010/01/26
    Author      : w58735
    Modification: Created file

******************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <string.h>
#include <pthread.h>

#include <assert.h>
#include <sys/mman.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <unistd.h>
#include "timer_api.h"
#include "osp.h"

#include "hi_unf_common.h"
#include "hi_unf_avplay.h"
#include "hi_unf_sound.h"
#include "hi_unf_disp.h"
#include "hi_unf_vo.h"
#include "hi_unf_demux.h"
#include "hi_adp_hdmi.h"
#include "hi_adp_mpi.h"
#include "basic_datatype.h"
#include "webconfig.h"
#include "hi_unf_vo.h"
#include "hi_unf_spi.h"

int spiopen()
{
    
    HI_S32 Ret;
    HI_UNF_SPI_ATTR_S  stAttr;

    Ret = HI_UNF_SPI_Open(HI_UNF_SPI_DEV_0);
    if (HI_SUCCESS != Ret)
    {
        LOGE("HI_UNF_SPI_Open Ret:0x%x\n",Ret);
        //return HI_FAILURE;
    }
    LOGD("HI_UNF_SPI_Open OK\n");

    DOFUNC_RETURN(HI_UNF_SPI_GetAttr(HI_UNF_SPI_DEV_0, &stAttr));

    DOFUNC_RETURN(HI_UNF_SPI_SetAttr(HI_UNF_SPI_DEV_0, &stAttr));

    DOFUNC_RETURN(HI_UNF_SPI_GetAttr(HI_UNF_SPI_DEV_0, &stAttr));

    LOGD("HI_UNF_SPI_GetAttr OK\n");
    LOGD("enDev:%d\n",stAttr.enDev);
    LOGD("csCfg:%d\n",stAttr.csCfg);
    LOGD("u32Baud:%d\n",stAttr.u32Baud);
    LOGD("enFrf:%d\n",stAttr.enFrf);
    LOGD("u32Dss:%d\n",stAttr.u32Dss);
    LOGD("enBigend:%d\n",stAttr.enBigend);
    //LOGD("unExtAttr:%d\n",stAttr.unExtAttr);
    return OK;

}

int spiclose()
{
    DOFUNC_RETURN(HI_UNF_SPI_Close(HI_UNF_SPI_DEV_0));

    return OK;

}
int spiSend(char *data, int len)
{
    CHECK_POINT_PARAM(data);
    DOFUNC_RETURN(HI_UNF_SPI_Write(HI_UNF_SPI_DEV_0,data,len));
    return OK;
}

char spisendtask[] = "PLAYTASK";
U32 spisendtaskId;

void spiSendTask(void)
{
    int i = 0;
    int rmsudp[3];
    int udpWarnFlag[3];
    int rmsmp3;
    int curplayIndex = 0;
    int ret = OK;
    char sendStr[1024];
    while (1)
    {
        sleep(1);
        
        continue;
    }
    return;
}

int spiInit()
{
    HI_S32 Ret;
    char str[160];
    HI_UNF_SPI_ATTR_S  stAttr;

    HI_UNF_SPI_Init();

    spiopen();

    OSPTaskCreate((char *)spisendtask, 32 * 1024, (void(*)(void))spiSendTask, OSP_PLAYTASK_PRIORITY, 0, 0,&spisendtaskId);
}



